import random
first = 0
second = 0
three = 0
four = 0

"""
这个以10为边长的正文形为主
"""

for i in range(0,1000000):
    x = random.randint(0,20) - 10
    y = random.randint(0,20) - 10

    if x < 0:
        first += 1
    else:
        if y < 0:
            second += 1
        else:

            # 计算点有没有在第三区域。就是判断 点有没有在三角形里面。

            x1, y1, x2, y2, x3, y3 = 0, 0, 0, 10, 10, 0
            xp, yp = x,y
            x1_2 = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1)
            x2_3 = (x3 - x2) * (yp - y2) - (y3 - y2) * (xp - x2)
            x3_1 = (x1 - x3) * (yp - y3) - (y1 - y3) * (xp - x3)

            if x1_2 < 0 and x2_3 < 0 and x3_1 < 0:
                three += 1
            elif x1_2 == 0 or x2_3 == 0 or x3_1 == 0:
                three += 1
            else:
                four += 1


print("落入第1区域的次数：",first)
print("落入第2区域的次数：",second)
print("落入第3区域的次数：",three)
print("落入第4区域的次数：",four)

print("概率：",(first+three)/1000000)










